package io.seata.samples.integration.order.service;

import java.util.UUID;


import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.seata.samples.integration.entity.TOrder;
import io.seata.samples.integration.order.mapper.TOrderMapper;
import io.seata.samples.integration.service.ITOrderService;
import io.seata.samples.integration.service.ITStorageService;
import io.seata.spring.annotation.GlobalTransactional;
import org.apache.dubbo.config.annotation.Reference;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.BeanUtils;
import org.springframework.transaction.annotation.Transactional;


/**
 * <p>
 *  服务实现类
 * </p>
 *
 * * @author lidong
 * @since 2019-09-04
 */
@Service
@Transactional
public class TOrderServiceImpl extends ServiceImpl<TOrderMapper, TOrder> implements ITOrderService {


    @Reference
    private ITStorageService storageService;
    @Override
    @GlobalTransactional(rollbackFor = Exception.class)//  seata事务
    public String add(TOrder tOrder) {
        storageService.decreaseStorage(1,1);
        System.out.println(1/0);
        boolean save = save(tOrder);
        return save+"";
    }



}
